package example2;

import org.apache.commons.io.FileUtils;
import org.junit.Test;

import java.io.File;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

public class ListTest {


    @Test
    public void t3() throws Exception {
        ArrayList<KVEntity> list = new ArrayList<>();

        list.add(new KVEntity("1","1"));
        list.add(new KVEntity("2","1"));
        list.add(new KVEntity("3","1"));
        list.add(new KVEntity("4","1"));

        List<KVEntity> list1 = list.stream().collect(Collectors.toList());
//        List<String> list2 = new ArrayList<>(list);
        List<KVEntity> list2 = new LinkedList<>(list);

        System.out.println(String.format("list.size()=%s ,list1.size()=%s ,list2.size()=%s", list.size(), list1.size(), list2.size()));
        System.out.println(list);
        System.out.println(list1);
        System.out.println(list2);

        for (KVEntity kvEntity : list) {
            kvEntity.setValue(kvEntity.getKey());
        }
        list.clear();

        System.out.println(String.format("list.size()=%s ,list1.size()=%s ,list2.size()=%s", list.size(), list1.size(), list2.size()));
        System.out.println(list);
        System.out.println(list1);
        System.out.println(list2);
        File file = FileUtils.getFile("");
        file.createNewFile();
        file.mkdir();
    }

}
